package game.block.command;

import game.block.Constants;
import game.block.entity.MovableEntity;
import game.block.tile.Tile;

public class TeleportCommand extends Command implements Constants {

    private MovableEntity block;
    private Tile tile;
    private Tile spawnTile;
    
    public TeleportCommand(MovableEntity block, Tile tile, Tile spawnTile){
        this.block=block;
        this.spawnTile=spawnTile;
        this.tile=tile;
    }
    
    @Override
    public void execute() {
        block.moveTo(spawnTile, 0);
        block.setCurrentTile(spawnTile);
        tile.remove(block);
        spawnTile.add(block);
    }

    @Override
    public void undo() {
        block.moveTo(tile, 0);
        block.setCurrentTile(tile);
        spawnTile.remove(block);
        tile.add(block);
    }

}
